#!/usr/bin/perl -w

use strict;

my $cnt_MIMs;
my %MIM_codes;
while (<>)
{
	/	^							# start at beginning of line
		(?:[^|]*\|){9}				# ignore first 9 fields
		([^|]*)\|					# save MIM code field (not including | terminator)
		(?:[^|]*\|){3}				# ignore next 3 fields
		([^|]*)						# save disease field
						/x;
	if ($1 ne '' && $2 ne '')
	{
		my ($MIM_code, $dis) = ($1,$2);
		
		if ($dis !~ /^(		[?\[]		|		# not begin with ? or [
							(\{\?)		)	/x)	# or {?
		{
			++$MIM_codes{$MIM_code};
			++$cnt_MIMs;
		}
	}
}
print join "\n", sort {$a <=> $b} keys %MIM_codes;
print STDERR "\t", scalar keys %MIM_codes, "\tMIM codes were retrieved from the morbid map.\n";
print STDERR "\t\t($cnt_MIMs disease entries were associated with MIM codes.)\n";
}	
